package com.leetcode;

import java.util.Scanner;

/**
 * @author Dennis Li
 * @date 2020/9/7 21:59
 */
public class NumOfChars_2 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        final String str = scanner.next().toLowerCase();

        int ch = scanner.next().charAt(0);

        if (ch >= 'A' && ch <= 'Z') {
            ch = ch + 'a' - 'A';
        }

        final int[] hash = new int[256];

        for (int i = 0; i < str.length(); i++) {
            hash[str.charAt(i)]++;
        }

        System.out.println(hash[ch]);
    }

}
